Skip to main content

Replay Playback

Overview

Feed.fm Replay is a product that allows clients to select songs from a catalog of independent label content to create a playlist that plays in the same order every time it's heard alongside your content.

It is designed for those who want to easily incorporate music into apps or content soundtracks and stream globally. It's an ideal solution for anyone tired of navigating extensive production music catalogs or settling for royalty-free options, offering a quicker way to access quality music that matches any vibe.

Replay stations are an extention of First play stations. The main difference being that replay station can be replayed multiple times in the exact same order unlike first play which can only be played back in a specific order once.

There are two ways to start playback of a Replay station:

  • searchForAndSetActiveStation (iOS SDK 5.8.0+, Android SDK 7.1.0+) — find the station, set it as the active station, and begin buffering audio in a single network request. This is the recommended approach.
  • setActiveStation with an advance value — pick a specific station from the station list yourself and start playback at a given offset into the station.

Finding and playing a Replay station with searchForAndSetActiveStation

The example below searches for a Replay station named "Replay Station X", sets it as the active station, and starts playback from the beginning of the station (advance = 0) as soon as audio is buffered. See the Station Search recipe for full details on search queries, filters, and error handling.

let queries: [FMStationSearchQuery] = [
.replay(withAdvance: 0, // play the station from the beginning
filter: ["name": "Replay Station X"])
]

let player = FMAudioPlayer.shared()

player.search(
forAndSetActiveStation: queries,
searchTimeoutMs: nil, // defaults to 2000ms
prepareToPlay: true,
prepareTimeoutMs: nil // defaults to 5000ms
) { audioItem, error in
if let error {
// no Replay station matched the search
print("station search failed: \(error)")
return
}

// "Replay Station X" is now active and audio is buffered
player.play()
}

Because Replay stations can be played back any number of times, the same search succeeds every time it is made — unlike a First Play station, which stops matching once the client has played through it. To start playback somewhere other than the beginning of the station, pass the number of seconds to skip as the advance (iOS) / at (Android) value.

Selecting a specific station and starting at an offset with setActiveStation

If you'd rather pick the station yourself — retrieve it from the player's station list and pass it to setActiveStation along with the number of seconds to advance into the station. Pass an advance of 0 to play the station from the beginning.

let player = FMAudioPlayer.shared()

if let station = player.stationList.getStationWithOptionKey("uuid",
value: "my-unique-replay-station-id" as NSString) {
// begin playback 90 seconds into the station;
// pass an advance of 0 to play from the beginning
player.setActiveStation(station, withAdvance: 90)
player.play()
}